import request from '@/utils/request'

export default {
    getAllDispatchsMessage(){
        const req = request({
            method: 'get',
            url: '/dgut/getAllDispatchMessage' 
        })
        return req;
    },
    addOneDispatch(Message) {
        console.log(Message);
        const req = request({
            method: 'post',
            url: '/dgut/addOneDispatchMessage',
            params: {
                dvid: Message.dvid,
                deid: Message.deid,
                dgid: Message.dgid,
                dcounts: Message.dcounts,
                dtype: Message.dtype
            }
        })
        return req;
    },
    search(searchMap){
        if (searchMap.did != "") {
            const req = request({
                method: 'get',
                url: '/dgut/getDispatchMessageByDid',
                params: {
                    did:searchMap.did
                }
            })
            return req;
        } else if (searchMap.dvid != "") {
            const req = request({
                method: 'get',
                url: '/dgut/getDispatchMessageByVid',
                params: {
                    dvid:searchMap.dvid
                }
            })
            return req;
        } else if (searchMap.dvphone != "") {
            const req = request({
                method: 'get',
                url: '/dgut/getDispatchMessageByPhone',
                params: {
                    dvphone:searchMap.dvphone
                }
            })
            return req;
        } else if (searchMap.dename != "") {
            const req = request({
                method: 'get',
                url: '/dgut/getDispatchMessageByEname',
                params: {
                    dename:searchMap.dename
                }
            })
            return req;
        } else if (searchMap.dgname != "") {
            const req = request({
                method: 'get',
                url: '/dgut/getDispatchMessageByGname',
                params: {
                    dgname:searchMap.dgname
                }
            })
            return req;
        }else {
            const req = request({
                method: 'get',
                url: '/dgut/getAllDispatchMessage' 
            })
            return req;
        }
    }
}